package com.mxcyk.serviceLogic;

import java.io.File;
import java.io.IOException;

import javax.swing.*;
import javax.swing.filechooser.FileSystemView;

import sun.awt.shell.ShellFolder;

/**
 * 功能：存储文件 图标 名字 路径
 * 
 * @author k
 * 
 */
final public class Appfile {

	private ImageIcon bigIcon = null;
	private ImageIcon smallIcon = null;
	public ImageIcon getSmallIcon() {
		return smallIcon;
	}


	public void setSmallIcon(ImageIcon smallIcon) {
		this.smallIcon = smallIcon;
	}


	private String AppName = null;
	private File AppPath = null;

	public Appfile(String AppPath) {
		this.AppPath = new File(AppPath);
		try {
			this.AppName = this.AppPath.getName();
		} catch (Exception e) {
			System.out.println("错误！再：AppFile类的构造函数中");
		}

		this.smallIcon = (ImageIcon) FileSystemView.getFileSystemView()
				.getSystemIcon(this.AppPath);//获得系统小图标
		this.bigIcon=(ImageIcon) GetbigIcon(this.AppPath);

	}
	
	
	/**获得系统的大图标
	 * @param path 为获得图标的路径 
	 */
	private Icon GetbigIcon(File path) {
		Icon bigIcon=null;
		try {
			
			ShellFolder shellFolder = ShellFolder.getShellFolder(path);
			bigIcon = new ImageIcon(shellFolder.getIcon(true));
			
		} catch (IOException ioe) {
			System.out.println("获得图标时出错");
			ioe.printStackTrace();
		}
		return bigIcon;
	}
	

	public ImageIcon getAppIcon() {
		return bigIcon;
	}

	public void setAppIcon(ImageIcon appIcon) {
		bigIcon = appIcon;
	}

	public String getAppName() {
		return AppName;
	}

	public void setAppName(String appName) {
		AppName = appName;
	}

	public File getAppPath() {
		return AppPath;
	}

	public void setAppPath(File appPath) {
		AppPath = appPath;
	}

	
	public static void main(String[] args) {
		Appfile path = new Appfile("H:\\JAVA\\Java源码\\text.exe");

		// System.out.println(" 字符位置："+ path.AppPath.lastIndexOf('.')+
		// path.AppPath.subSequence(2, 5));
	}
}
